home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.05 May 91 / StripStyle FKEY / StripStyle FKEY.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-11  |  1012 b   |  34 lines  |  [TEXT/KAHL]

  1. /*  Used to remove the style from any text that is in the scrap. */
  2. /*  Written by Thomas A. S. Nielsen.  */
  3. /*  No copyright what-so-ever! */
  4.  
  5. Handle NewClearSysHandle(long size){                    /* the function name says it all */
  6.     asm{
  7.         move.l            size,d0
  8.         NewHandle    CLEAR+SYS
  9.         move.l            a0,d0
  10.         }
  11.     }
  12.     
  13. void main(void){
  14.     long    scrapsize, offset;
  15.     Handle     h;
  16.     
  17.     scrapsize=0L;
  18.     h=0L;
  19.  
  20.     if (!(h=NewClearSysHandle(0)))                            /* Get scrap will resize our Handle below */
  21.         goto returnpoint;                                             /* not enough memory, could beep */
  22.     scrapsize=GetScrap(h,'TEXT',&offset);             /* get the clipboard tex t*/
  23.     if (scrapsize>0){                                                
  24.         SetHandleSize(h,scrapsize+(scrapsize&1));    /* make sure handle size if even (read somewhere) */
  25.         ZeroScrap();                                                    /* clear out all rsrc from scrap */
  26.         PutScrap(scrapsize,'TEXT',*h);                    /* put text back */
  27.         SystemEdit(3);                                                /* this is the TRICK, it took me forever to figure this out. */
  28.         }
  29.  
  30. returnpoint:                                                            /* clean up */
  31.     if (h)
  32.             DisposHandle(h);
  33.     }
  34.